package cn.leelei.hibernate.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

/**
 *自定义主键生成策略
 * 
 * @author Nike
 *
 */
// 添加注解实体类
@Entity
// 添加注解表表名为User
@Table(name = "Orders")
public class Orders {
	// 映射主键
	@Id
	// UUID 主键的生成策略
	@GenericGenerator(name="ordersTime", strategy = "cn.leelei.hibernate.utils.CustomStrategy")
	@GeneratedValue(generator = "ordersTime")
	private String id;// 用户表的id 字段
	@Column(name = "UserName") // 普通列名  
	private String UserName;// 用户表的UserName 字段
	@Column(name = "PassWord") // 普通列名
	private String PassWord;// 用户表的PassWord 字段
	@Column(name = "Address") // 普通列名
	private String Address;// 用户表的Address 字段
	@Formula("(SELECT count(1) FROM student AS stu WHERE stu.id=id)")// sql 语句片段  缩写SQL语句
	private Integer Count;// 统计student表中数据
	
	
	

	public Integer getCount() {
		return Count;
	}

	public void setCount(Integer count) {
		Count = count;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUserName() {
		return UserName;
	}

	public void setUserName(String userName) {
		UserName = userName;
	}

	public String getPassWord() {
		return PassWord;
	}

	public void setPassWord(String passWord) {
		PassWord = passWord;
	}

	public String getAddress() {
		return Address;
	}

	public void setAddress(String address) {
		Address = address;
	}

	
	public Orders(String id, String userName, String passWord, String address) {
		super();
		this.id = id;
		UserName = userName;
		PassWord = passWord;
		Address = address;
	}

	public Orders() {
		super();

	}

}
